package com.wubotao.algorithm;

public class InsertionSort {

	public static void sort(double[] data) {
		double temp = 0;

		for (int i = 1; i < data.length; i++) {
			int j = i - 1;
			temp = data[i];
			for (; j >= 0 && temp < data[j]; j--) {
				data[j + 1] = data[j];
			}
			data[j + 1] = temp;
		}

	}

	public static void main(String[] args) {
		double[] c = { 4, 9, 23, 1, 45, 27, 5, 2 };
		sort(c);
		for (int i = 0; i < c.length; i++)
			System.out.println("插入排序：" + c[i]);
	}
}


